package com.fywsy.fyweb.strategy;

import com.fywsy.fyweb.entity.SendItem;
import com.fywsy.fyweb.utils.RestTemplateUtil;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

/**
 * 万剑OL
 * 注解gameId对应数据库游戏id
 * 注解GongnengMethod对应数据库功能id
 */
@Component
@GameId(44)
public class WanjianOlGameStrategy extends BaseGameStrategy {

    public static final String URL = "http://43.159.53.8:82/gmss/user/gmquery.php";

    /**
     * type: charge
     * uid: 风云
     * qu: 1
     * checknum: diyao88
     * chargenum: 1
     * chargetype: 2
     *
     * @param item
     * @return
     */
    @GongnengMethod(4401)
    public String pay(SendItem item) {
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        params.add("checknum", "diyao88");
        params.add("type", "charge");
        params.add("qu", item.qufu);

        params.add("uid", item.uid);
        params.add("chargenum", "1");
        params.add("chargetype", item.itemId);
        RestTemplateUtil.sendPostForm(URL, params);
        return "已发送,直接到账";
    }


    /**
     * type: mail
     * uid: 风云
     * item: 314001
     * num: 100
     * qu: 1
     * checknum: diyao88
     * title: titlrc
     * content: ccccc
     *
     * @param item
     * @return
     */
    @GongnengMethod(4402)
    public String mail(SendItem item) {
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        params.add("checknum", "diyao88");
        params.add("type", "mail");
        params.add("title", "风云");
        params.add("content", "发福利");
        params.add("qu", item.qufu);

        params.add("uid", item.uid);
        params.add("num", item.number);
        params.add("item", item.itemId);
        String s = RestTemplateUtil.sendPostForm(URL, params);
        return "已发送,邮件查收";
    }



    @GongnengMethod(9)
    public String clear(SendItem item) {
        System.out.println("清除成功");
        return "清除成功";
    }

    public static void main(String[] args) {
        SendItem item = new SendItem();
        item.uid = "风云";
        item.number = "2";
        item.itemId = "606501";
        item.qufu = "1";
        System.out.println(new WanjianOlGameStrategy().mail(item));
    }
}

